﻿@model DataAccess.Cliente

@{
    ViewBag.Title = "Cliente";
}

<div class="centralcontainer rounded-corners">
    <!-- BODY -->
    <table width="100%" cellpadding="20px">
        <tr>
            <td>
                @{
                    if (Model != null)
                    {
                        <h1 class="rounded-corners">Editar cliente</h1>
                        <p>
                            Este módulo le permite modificar el cliente.
                        </p>
                    }
                    else
                    {
                        <h1 class="rounded-corners">Nuevo cliente</h1>
                        <p>
                            Este módulo le permite crear un cliente.
                        </p>
                    }
                }
                <br />
                <div id="DivMensajeria" class="Mensajeria">
                    @if (ViewData["mensajeSuccess"] != null)
                    {
                        @Html.Partial("Success", ViewData["mensajeSuccess"].ToString())
                    }
                    else
                    {
                        @Html.Partial("Warning", "Todos los campos son obligatorios")                        
                    }
                </div>
                <div class="divformulario rounded-corners">
                    @{
                    
                        string url;
                        if (Model != null)
                        {
                            url = Url.Action("UpdateCliente");
                        }
                        else
                        {
                            url = Url.Action("InsertCliente");
                        }
                    }
                    <form action="@url" method="post" enctype="multipart/form-data"
						id="formulario">
                    <table align="left" width="100%" style="float: left;" class="edit_table">
                        <tr>
                            <td align="left" style="border-bottom: 1px solid #757575 !important">
                                @if (Model != null)
                                {
                                    <input type="hidden" value="@Model.Id" name="idCliente" />
                                }
                                <label>
                                    Nombre</label>
                            </td>
                            <td align="left" style="border-bottom: 1px solid #757575 !important">
                                <input type="text" name="nombre" value="@(Model != null ? Model.Nombre : "")"  
                                required="required"/>
                            </td>
                        </tr>                        
                        @if (Model != null)
                        {
                            <tr>
                                <td align="left" colspan="2">
                                    <label>
                                        Imagen color actual:</label>
                                </td>
                            </tr>
                            <tr class="boder_bottom">
                                <td align="left" colspan="2">
                                    <img src="@Url.Action("GetImagen", "Imagen", new { idImagen = Model.IdImagenColor })" alt="@Model.Nombre" />
                                </td>
                            </tr>                                                        
                        }
                        <tr>
                            <td align="left" style="border-bottom: 1px solid #757575 !important">
                                <label>
                                    Imagen color (123456px X 123456px)</label>
                            </td>
                            <td align="left" style="border-bottom: 1px solid #757575 !important">
                                <input type="file" name="imagenColor" @(Model == null ? "required='required'" : "") />
                            </td>
                        </tr>

                        @if (Model != null)
                        {
                            <tr>
                                <td align="left" colspan="2">
                                    <label>
                                        Imagen blanco y negro actual:</label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" colspan="2">
                                    <img src="@Url.Action("GetImagen", "Imagen", new { idImagen = Model.IdImagenBlancoNegro })" alt="@Model.Nombre" />
                                </td>
                            </tr>                                                        
                        }
                        <tr>
                            <td align="left">
                                <label>
                                    Imagen blanco y negro (123456px X 123456px)</label>
                            </td>
                            <td align="left">
                                <input type="file" name="imagenBlancoNegro" @(Model == null ? "required='required'" : "") />
                            </td>
                        </tr>
                    </table>
                    <table align="left" cellspacing="20px" width="100%" style="float: left;">
                        <tr>
                            <td align="right">
                                <input type="submit" value="Guardar" class="boton tahoma16" style="border-width: 0px;" />
                            </td>
                            <td align="left">
                                <input type="button" value="Volver" class="boton tahoma16" style="border-width: 0px;"
										onclick="javascript:window.top.location.href='@Url.Action("Index")';" />
                            </td>
                        </tr>
                        <tr id="LoaderNew" style="display: none;">
                            <td align="center" colspan="2">
                                <img alt="Loading..." src="@Url.Content("~/Content/img/loader.gif")" />
                            </td>
                        </tr>
                    </table>
                    </form>
                </div>
                <div class="clean-floats">
                </div>
            </td>
        </tr>
    </table>
</div>

@section navegacion{
    <a href="@Url.Action("Index", "Home")" class="tahoma14 black">Home </a>&nbsp;&gt;&nbsp;
    <a href="@Url.Action("Index")" class="tahoma14 black">Clientes</a>&nbsp;&gt;&nbsp;
    <label class="tahoma14 black">
        Cliente
    </label>
}

